import {fromJS} from "immutable"
import *  as actionType from "./actionType"

const defaultState = fromJS({
  topicList: [],
  articleList: [],
  recommendList: [],
  WriterList: [],
  articlePage: 1,
  showScroll: false
});

export default (state = defaultState, action) => {
  switch (action.type) {
    case actionType.CHANGE_HOME_DATA:
      return state.merge({
        topicList: fromJS(action.topicList),
        articleList: fromJS(action.articleList),
        recommendList: fromJS(action.recommendList),
        WriterList: fromJS(action.WriterList)
      })
    case actionType.ADD_LIST:
      return state.merge({
        "articleList": state.get("articleList").concat(action.list),
        "articlePage": action.nextPage
      })
    case actionType.SORLLCHANGE:
      return state.set("showScroll", action.show);
    default:
      return state;
  }
}
